{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](https://www.haskell.org/img/haskell-logo.svg)\n",
    "\n",
    "IHaskell Notebook\n",
    "===\n",
    "Hello, and welcome to the **IHaskell Notebook**. IHaskell Notebook is similar to an interactive shell along the lines of GHCi. However, it is much more powerful, and provides features such as syntax highlighting, autocompletion, multi-line input cells, integrated documentation, rich output visualization, and more. In this notebook, I'd like to demonstrate many of the awesome features IHaskell provides.\n",
    "\n",
    "IHaskell is implemented as a language kernel for the [Jupyter](https://jupyter.org) project, which means that although the entire thing is written only in Haskell, we get a beautiful notebook interface practically for free.\n",
    "\n",
    "We can start with very simple Haskell expressions:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "\"Hello, World!\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- First of all, we can evaluate simple expressions.\n",
    "3 + 5\n",
    "\"Hello, \" ++ \"World!\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As you can see, each input cell get an execution number. The first input cell is labeled `In [1]`. Just like in GHCi, the output of the last executed statement or expression is available via the `it` variable - however, in addition, the output of the $n$th cell is available via the `itN` variable. For example, if we wanted to see what the first cell printed, we can go ahead and output that:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"Hello, World!\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "it1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In addition to simple code cells such as the ones you see, you can also have other types of cells. All of this inline text, for instance, is written using Markdown cells, which support the majority of Github markdown syntax. This lets you embed images and formatting and arbitrary HTML interspersed with your Haskell code. In addition, you can export these notebooks into HTML or even as presentations using `reveal.js`. \n",
    "\n",
    "Alright, back to code. Let's do something slightly fancier:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"Hello, World!\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- Unlike in GHCi, we can have multi-line expressions.\n",
    "concat [\n",
    "  \"Hello\",\n",
    "  \", \",\n",
    "  \"World!\"\n",
    "  ] :: String"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In addition to multi-line expressions, IHaskell supports most things that you could put in a standard Haskell file. For example, we can  have function bindings without the `let` that GHCi requires. (As long as you group type signatures and their corresponding declarations together, you can use pattern matching and put signatures on your top-level declarations!)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "100"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "12"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "thing :: String -> Int -> Int\n",
    "thing \"no\" _ = 100\n",
    "thing str int = int + length str\n",
    "\n",
    "thing \"no\" 10\n",
    "thing \"ah\" 10"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So far we've just looked at pure functions, but nothing is stopping us from doing IO."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"What's going on?\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "print \"What's going on?\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "IHaskell supports most GHC extensions via the `:extension` directive (or any shorthand thereof)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "ename": "",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "<interactive>:1:1: error:\n    • ‘Thing’ has no constructors (EmptyDataDecls permits this)\n    • In the data declaration for ‘Thing’"
     ]
    }
   ],
   "source": [
    "-- We can disable extensions.\n",
    ":ext NoEmptyDataDecls\n",
    "data Thing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "-- And enable extensions.\n",
    ":ext EmptyDataDecls\n",
    "data Thing"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Data declarations do pretty much what you expect, and work fine on multiple lines. If a declaration turns out to be not quite what you wanted, you can just go back, edit it, and re-evaluate the code cell."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[A \"Hello\",B 10]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- Various data declarations work fine.\n",
    "data One\n",
    "     = A String\n",
    "     | B Int\n",
    "     deriving Show\n",
    "\n",
    "print [A \"Hello\", B 10]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Although this doesn't hold everywhere, we've tried to keep IHaskell relatively similar to GHCi in terms of naming. So, just like in GHCi, you can inspect types with `:type` (or shorthands):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>/* Styles used for the Hoogle display in the pager */\n",
       ".hoogle-doc {\n",
       "display: block;\n",
       "padding-bottom: 1.3em;\n",
       "padding-left: 0.4em;\n",
       "}\n",
       ".hoogle-code {\n",
       "display: block;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "}\n",
       ".hoogle-text {\n",
       "display: block;\n",
       "}\n",
       ".hoogle-name {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-head {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-sub {\n",
       "display: block;\n",
       "margin-left: 0.4em;\n",
       "}\n",
       ".hoogle-package {\n",
       "font-weight: bold;\n",
       "font-style: italic;\n",
       "}\n",
       ".hoogle-module {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-class {\n",
       "font-weight: bold;\n",
       "}\n",
       ".get-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "white-space: pre-wrap;\n",
       "}\n",
       ".show-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "margin-left: 1em;\n",
       "}\n",
       ".mono {\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "}\n",
       ".err-msg {\n",
       "color: red;\n",
       "font-style: italic;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "display: block;\n",
       "}\n",
       "#unshowable {\n",
       "color: red;\n",
       "font-weight: bold;\n",
       "}\n",
       ".err-msg.in.collapse {\n",
       "padding-top: 0.7em;\n",
       "}\n",
       ".highlight-code {\n",
       "white-space: pre;\n",
       "font-family: monospace;\n",
       "}\n",
       ".suggestion-warning { \n",
       "font-weight: bold;\n",
       "color: rgb(200, 130, 0);\n",
       "}\n",
       ".suggestion-error { \n",
       "font-weight: bold;\n",
       "color: red;\n",
       "}\n",
       ".suggestion-name {\n",
       "font-weight: bold;\n",
       "}\n",
       "</style><span class='get-type'>3 + 3 :: forall a. Num a => a</span>"
      ],
      "text/plain": [
       "3 + 3 :: forall a. Num a => a"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- We can look at types like in GHCi.\n",
    ":ty 3 + 3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The same goes for the `:info` command. However, unlike GHCi, which simply prints info, the IHaskell notebook brings up a separate pane."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {},
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- What is the Integral typeclass?\n",
    ":info Integral"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you're looking at this notebook after it's been exported to HTML, you won't be able to see this interactive pane that pops up after this is evaluated. However, you can disable the interactive pager, and instead just show the output below the cell:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "-- Only takes effect on later cells, so stick it in its own cell.\n",
    ":opt no-pager"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {},
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<style>/* Styles used for the Hoogle display in the pager */\n",
       ".hoogle-doc {\n",
       "display: block;\n",
       "padding-bottom: 1.3em;\n",
       "padding-left: 0.4em;\n",
       "}\n",
       ".hoogle-code {\n",
       "display: block;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "}\n",
       ".hoogle-text {\n",
       "display: block;\n",
       "}\n",
       ".hoogle-name {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-head {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-sub {\n",
       "display: block;\n",
       "margin-left: 0.4em;\n",
       "}\n",
       ".hoogle-package {\n",
       "font-weight: bold;\n",
       "font-style: italic;\n",
       "}\n",
       ".hoogle-module {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-class {\n",
       "font-weight: bold;\n",
       "}\n",
       ".get-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "white-space: pre-wrap;\n",
       "}\n",
       ".show-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "margin-left: 1em;\n",
       "}\n",
       ".mono {\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "}\n",
       ".err-msg {\n",
       "color: red;\n",
       "font-style: italic;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "display: block;\n",
       "}\n",
       "#unshowable {\n",
       "color: red;\n",
       "font-weight: bold;\n",
       "}\n",
       ".err-msg.in.collapse {\n",
       "padding-top: 0.7em;\n",
       "}\n",
       ".highlight-code {\n",
       "white-space: pre;\n",
       "font-family: monospace;\n",
       "}\n",
       ".suggestion-warning { \n",
       "font-weight: bold;\n",
       "color: rgb(200, 130, 0);\n",
       "}\n",
       ".suggestion-error { \n",
       "font-weight: bold;\n",
       "color: red;\n",
       "}\n",
       ".suggestion-name {\n",
       "font-weight: bold;\n",
       "}\n",
       "</style><div style='background: rgb(247, 247, 247);'><form><textarea id='code'>class (Real a, Enum a) => Integral a where\n",
       "  quot :: a -> a -> a\n",
       "  rem :: a -> a -> a\n",
       "  div :: a -> a -> a\n",
       "  mod :: a -> a -> a\n",
       "  quotRem :: a -> a -> (a, a)\n",
       "  divMod :: a -> a -> (a, a)\n",
       "  toInteger :: a -> Integer\n",
       "  {-# MINIMAL quotRem, toInteger #-}\n",
       "  \t-- Defined in ‘GHC.Real’\n",
       "instance Integral Word -- Defined in ‘GHC.Real’\n",
       "instance Integral Integer -- Defined in ‘GHC.Real’\n",
       "instance Integral Int -- Defined in ‘GHC.Real’\n",
       "</textarea></form></div><script>CodeMirror.fromTextArea(document.getElementById('code'), {mode: 'haskell', readOnly: 'nocursor'});</script>"
      ],
      "text/plain": [
       "class (Real a, Enum a) => Integral a where\n",
       "  quot :: a -> a -> a\n",
       "  rem :: a -> a -> a\n",
       "  div :: a -> a -> a\n",
       "  mod :: a -> a -> a\n",
       "  quotRem :: a -> a -> (a, a)\n",
       "  divMod :: a -> a -> (a, a)\n",
       "  toInteger :: a -> Integer\n",
       "  {-# MINIMAL quotRem, toInteger #-}\n",
       "  \t-- Defined in ‘GHC.Real’\n",
       "instance Integral Word -- Defined in ‘GHC.Real’\n",
       "instance Integral Integer -- Defined in ‘GHC.Real’\n",
       "instance Integral Int -- Defined in ‘GHC.Real’"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    ":info Integral"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can now write slightly more complicated scripts."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1\n",
       "2\n",
       "3\n",
       "4\n",
       "5"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- Results are printed as we go, even from a single expression.\n",
    "import Control.Monad\n",
    "import Control.Concurrent\n",
    "\n",
    "forM_ [1..5] $ \\x -> do\n",
    "  print x\n",
    "  threadDelay $ 200 * 1000"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is where the similarities with GHCi end, and the particularly shiny features of IHaskell begin.\n",
    "\n",
    "Although looking at text outputs is often enough, there are many times where we really want a richer output. Suppose we have a custom data type for color:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "data Color = Red | Green | Blue"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If we were playing around with designing GUI applications, for instance, we might want to actually *see* these colors, instead of just seeing the text \"Red\", \"Green\", and \"Blue\" when we are debugging.\n",
    "\n",
    "IHaskell lets you define a custom display mechanism for any data type via its `IHaskellDisplay` typeclass. Since you can  use IHaskell in console mode as well as notebook mode, you can provide a list of display outputs for any data type, and the frontend will simply choose the best one. Here's how you would implement a very simple display mechanism for this `Color` data type:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "import IHaskell.Display\n",
    "\n",
    "instance IHaskellDisplay Color where\n",
    "  display color = return $ Display [html code]\n",
    "    where\n",
    "      code = concat [\"<div style='font-weight: bold; color:\"\n",
    "                    , css color\n",
    "                    , \"'>Look!</div>\"]\n",
    "      css Red   = \"red\"\n",
    "      css Blue  = \"blue\"\n",
    "      css Green = \"green\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Once we define a custom `display :: a -> IO Display` function, we can simply output a `Color`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>/* Styles used for the Hoogle display in the pager */\n",
       ".hoogle-doc {\n",
       "display: block;\n",
       "padding-bottom: 1.3em;\n",
       "padding-left: 0.4em;\n",
       "}\n",
       ".hoogle-code {\n",
       "display: block;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "}\n",
       ".hoogle-text {\n",
       "display: block;\n",
       "}\n",
       ".hoogle-name {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-head {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-sub {\n",
       "display: block;\n",
       "margin-left: 0.4em;\n",
       "}\n",
       ".hoogle-package {\n",
       "font-weight: bold;\n",
       "font-style: italic;\n",
       "}\n",
       ".hoogle-module {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-class {\n",
       "font-weight: bold;\n",
       "}\n",
       ".get-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "white-space: pre-wrap;\n",
       "}\n",
       ".show-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "margin-left: 1em;\n",
       "}\n",
       ".mono {\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "}\n",
       ".err-msg {\n",
       "color: red;\n",
       "font-style: italic;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "display: block;\n",
       "}\n",
       "#unshowable {\n",
       "color: red;\n",
       "font-weight: bold;\n",
       "}\n",
       ".err-msg.in.collapse {\n",
       "padding-top: 0.7em;\n",
       "}\n",
       ".highlight-code {\n",
       "white-space: pre;\n",
       "font-family: monospace;\n",
       "}\n",
       ".suggestion-warning { \n",
       "font-weight: bold;\n",
       "color: rgb(200, 130, 0);\n",
       "}\n",
       ".suggestion-error { \n",
       "font-weight: bold;\n",
       "color: red;\n",
       "}\n",
       ".suggestion-name {\n",
       "font-weight: bold;\n",
       "}\n",
       "</style><div style='font-weight: bold; color:red'>Look!</div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<style>/* Styles used for the Hoogle display in the pager */\n",
       ".hoogle-doc {\n",
       "display: block;\n",
       "padding-bottom: 1.3em;\n",
       "padding-left: 0.4em;\n",
       "}\n",
       ".hoogle-code {\n",
       "display: block;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "}\n",
       ".hoogle-text {\n",
       "display: block;\n",
       "}\n",
       ".hoogle-name {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-head {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-sub {\n",
       "display: block;\n",
       "margin-left: 0.4em;\n",
       "}\n",
       ".hoogle-package {\n",
       "font-weight: bold;\n",
       "font-style: italic;\n",
       "}\n",
       ".hoogle-module {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-class {\n",
       "font-weight: bold;\n",
       "}\n",
       ".get-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "white-space: pre-wrap;\n",
       "}\n",
       ".show-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "margin-left: 1em;\n",
       "}\n",
       ".mono {\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "}\n",
       ".err-msg {\n",
       "color: red;\n",
       "font-style: italic;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "display: block;\n",
       "}\n",
       "#unshowable {\n",
       "color: red;\n",
       "font-weight: bold;\n",
       "}\n",
       ".err-msg.in.collapse {\n",
       "padding-top: 0.7em;\n",
       "}\n",
       ".highlight-code {\n",
       "white-space: pre;\n",
       "font-family: monospace;\n",
       "}\n",
       ".suggestion-warning { \n",
       "font-weight: bold;\n",
       "color: rgb(200, 130, 0);\n",
       "}\n",
       ".suggestion-error { \n",
       "font-weight: bold;\n",
       "color: red;\n",
       "}\n",
       ".suggestion-name {\n",
       "font-weight: bold;\n",
       "}\n",
       "</style><div style='font-weight: bold; color:green'>Look!</div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<style>/* Styles used for the Hoogle display in the pager */\n",
       ".hoogle-doc {\n",
       "display: block;\n",
       "padding-bottom: 1.3em;\n",
       "padding-left: 0.4em;\n",
       "}\n",
       ".hoogle-code {\n",
       "display: block;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "}\n",
       ".hoogle-text {\n",
       "display: block;\n",
       "}\n",
       ".hoogle-name {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-head {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-sub {\n",
       "display: block;\n",
       "margin-left: 0.4em;\n",
       "}\n",
       ".hoogle-package {\n",
       "font-weight: bold;\n",
       "font-style: italic;\n",
       "}\n",
       ".hoogle-module {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-class {\n",
       "font-weight: bold;\n",
       "}\n",
       ".get-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "white-space: pre-wrap;\n",
       "}\n",
       ".show-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "margin-left: 1em;\n",
       "}\n",
       ".mono {\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "}\n",
       ".err-msg {\n",
       "color: red;\n",
       "font-style: italic;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "display: block;\n",
       "}\n",
       "#unshowable {\n",
       "color: red;\n",
       "font-weight: bold;\n",
       "}\n",
       ".err-msg.in.collapse {\n",
       "padding-top: 0.7em;\n",
       "}\n",
       ".highlight-code {\n",
       "white-space: pre;\n",
       "font-family: monospace;\n",
       "}\n",
       ".suggestion-warning { \n",
       "font-weight: bold;\n",
       "color: rgb(200, 130, 0);\n",
       "}\n",
       ".suggestion-error { \n",
       "font-weight: bold;\n",
       "color: red;\n",
       "}\n",
       ".suggestion-name {\n",
       "font-weight: bold;\n",
       "}\n",
       "</style><div style='font-weight: bold; color:blue'>Look!</div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "Red\n",
    "Green\n",
    "Blue"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `DisplayData` type has several constructors which let you display your data as plain text, HTML, images (SVG, PNG, JPG), or even as LaTeX code.\n",
    "\n",
    "In order to ship an extension for IHaskell, simply create a package named `ihaskell-thing` with a module named `IHaskell.Display.Thing`. As long as `ihaskell-thing` is installed, IHaskell will detect and use it automatically.\n",
    "\n",
    "A number of packages already exist, which we can briefly look at."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `ihaskell-aeson` package adds a display for [Aeson](http://hackage.haskell.org/package/aeson) JSON `Value` types. These are automatically formatted as JSON, rather than as Haskell values:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "null"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "true"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "{\n",
       "    \"x\": 3,\n",
       "    \"y\": 2\n",
       "}"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- Aeson JSON data types are displayed nicely.\n",
    ":ext OverloadedStrings\n",
    "\n",
    "import Data.Aeson\n",
    "\n",
    "data Coord  = Coord { x :: Double, y :: Double }\n",
    "instance ToJSON Coord where\n",
    "   toJSON (Coord x y) = object [\"x\" .= x, \"y\" .= y]\n",
    "\n",
    "Null\n",
    "Bool True\n",
    "toJSON (Coord 3 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "-- Turn off SVG output\n",
    ":option no-svg"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `ihaskell-blaze` package lets you play around with HTML straight from within IHaskell using the [Blaze](http://jaspervdj.be/blaze/tutorial.html) library."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>/* Styles used for the Hoogle display in the pager */\n",
       ".hoogle-doc {\n",
       "display: block;\n",
       "padding-bottom: 1.3em;\n",
       "padding-left: 0.4em;\n",
       "}\n",
       ".hoogle-code {\n",
       "display: block;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "}\n",
       ".hoogle-text {\n",
       "display: block;\n",
       "}\n",
       ".hoogle-name {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-head {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-sub {\n",
       "display: block;\n",
       "margin-left: 0.4em;\n",
       "}\n",
       ".hoogle-package {\n",
       "font-weight: bold;\n",
       "font-style: italic;\n",
       "}\n",
       ".hoogle-module {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-class {\n",
       "font-weight: bold;\n",
       "}\n",
       ".get-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "white-space: pre-wrap;\n",
       "}\n",
       ".show-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "margin-left: 1em;\n",
       "}\n",
       ".mono {\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "}\n",
       ".err-msg {\n",
       "color: red;\n",
       "font-style: italic;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "display: block;\n",
       "}\n",
       "#unshowable {\n",
       "color: red;\n",
       "font-weight: bold;\n",
       "}\n",
       ".err-msg.in.collapse {\n",
       "padding-top: 0.7em;\n",
       "}\n",
       ".highlight-code {\n",
       "white-space: pre;\n",
       "font-family: monospace;\n",
       "}\n",
       ".suggestion-warning { \n",
       "font-weight: bold;\n",
       "color: rgb(200, 130, 0);\n",
       "}\n",
       ".suggestion-error { \n",
       "font-weight: bold;\n",
       "color: red;\n",
       "}\n",
       ".suggestion-name {\n",
       "font-weight: bold;\n",
       "}\n",
       "</style><div style=\"color: red\">\n",
       "    <p>\n",
       "        This is an example of BlazeMarkup syntax.\n",
       "    </p>\n",
       "    <b>\n",
       "        Hello\n",
       "    </b>\n",
       "</div>\n"
      ],
      "text/plain": [
       "<div style=\"color: red\">\n",
       "    <p>\n",
       "        This is an example of BlazeMarkup syntax.\n",
       "    </p>\n",
       "    <b>\n",
       "        Hello\n",
       "    </b>\n",
       "</div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<style>/* Styles used for the Hoogle display in the pager */\n",
       ".hoogle-doc {\n",
       "display: block;\n",
       "padding-bottom: 1.3em;\n",
       "padding-left: 0.4em;\n",
       "}\n",
       ".hoogle-code {\n",
       "display: block;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "}\n",
       ".hoogle-text {\n",
       "display: block;\n",
       "}\n",
       ".hoogle-name {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-head {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-sub {\n",
       "display: block;\n",
       "margin-left: 0.4em;\n",
       "}\n",
       ".hoogle-package {\n",
       "font-weight: bold;\n",
       "font-style: italic;\n",
       "}\n",
       ".hoogle-module {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-class {\n",
       "font-weight: bold;\n",
       "}\n",
       ".get-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "white-space: pre-wrap;\n",
       "}\n",
       ".show-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "margin-left: 1em;\n",
       "}\n",
       ".mono {\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "}\n",
       ".err-msg {\n",
       "color: red;\n",
       "font-style: italic;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "display: block;\n",
       "}\n",
       "#unshowable {\n",
       "color: red;\n",
       "font-weight: bold;\n",
       "}\n",
       ".err-msg.in.collapse {\n",
       "padding-top: 0.7em;\n",
       "}\n",
       ".highlight-code {\n",
       "white-space: pre;\n",
       "font-family: monospace;\n",
       "}\n",
       ".suggestion-warning { \n",
       "font-weight: bold;\n",
       "color: rgb(200, 130, 0);\n",
       "}\n",
       ".suggestion-error { \n",
       "font-weight: bold;\n",
       "color: red;\n",
       "}\n",
       ".suggestion-name {\n",
       "font-weight: bold;\n",
       "}\n",
       "</style><img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"70\">\n",
       "<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"140\">\n",
       "<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"210\">\n",
       "<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"280\">\n",
       "<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"350\">\n"
      ],
      "text/plain": [
       "<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"70\">\n",
       "<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"140\">\n",
       "<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"210\">\n",
       "<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"280\">\n",
       "<img src=\"https://www.google.com/images/srpr/logo11w.png\" width=\"350\">"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- Small bits of HTML generated via Blaze are displayed.\n",
    "\n",
    "import Prelude hiding (div, id)\n",
    "import Text.Blaze.Html4.Strict hiding (map, style)\n",
    "import Text.Blaze.Html4.Strict.Attributes\n",
    "\n",
    "div ! style \"color: red\" $ do\n",
    "    p \"This is an example of BlazeMarkup syntax.\"\n",
    "    b \"Hello\"\n",
    "    \n",
    "forM [1..5] $ \\size -> do\n",
    "  let s = toValue $ size * 70\n",
    "  img ! src \"https://www.google.com/images/srpr/logo11w.png\" ! width s"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `ihaskell-diagrams` package allows you to experiment with the [diagrams](http://projects.haskell.org/diagrams/) package. It requires the Cairo backend."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWIAAAFiCAIAAABDPkUtAAAABmJLR0QA/wD/AP+gvaeTAAAgAElEQVR4nO3dd3hUVfoH8HMLhCLFFVSsrA2s6Cqs5RH3cXddxYI+oK6yLqI+IkJ6Aomk0ENIBCQhQkAiJbA0CSC9KIL0EiHBhBJIAZJAEtIzmVt+f9yfY5x22zn33pl5P/8tK/Oee/PmSzLz3nOonj179u/fHwEAgIvGxsY9e/aw/fv337Rpk9mLAQBYUWFhYd++fWmzlwEAsDqICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJ8AeCIJi9BGA5EBPgDyIjIwsLC81eBbAWiAnwu/z8/LS0tLCwMLMXAqwFYgL8LjQ0VBCErVu3btmyxey1AAuBmAD/LycnZ9euXaIoMgwTEhJit9vNXhGwCogJgBBCra2tERERDMMghHieP3/+fHp6utmLAlYBMQEQQmjWrFkXL17ked7xJ/Hx8RUVFSYuCVgHxARAFRUVU6ZMEUXR8SeiKLa0tEyYMMG8RQELgZgAKCYmprm52ekPeZ6fP3/+sWPHT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AgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAyICQCADIgJAIAMiAkAgAy2sbGxsLDQ7GUAAKzowoULZi8BAOAL/g+AxO9PT9D9YwAAAABJRU5ErkJggg=="
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- We can draw diagrams, right in the notebook.\n",
    ":extension NoMonomorphismRestriction FlexibleContexts TypeFamilies\n",
    "import Diagrams.Prelude\n",
    "\n",
    "-- By Brent Yorgey\n",
    "-- Draw a Sierpinski triangle!\n",
    "sierpinski 1 = eqTriangle 1\n",
    "sierpinski n =     s\n",
    "                  ===\n",
    "               (s ||| s) # centerX\n",
    "  where s = sierpinski (n-1)\n",
    "\n",
    "-- The `diagram` function is used to display them in the notebook.\n",
    "diagram $ sierpinski 4\n",
    "            # centerXY\n",
    "            # fc black\n",
    "          `atop` square 10\n",
    "                   # fc white"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Just like with Diagrams, `ihaskell-charts` allows you to use the [Chart](https://github.com/timbod7/haskell-chart/wiki) library for plotting from within IHaskell. (You will need to install `cairo` as well, which may be a bit of a hassle.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAcIAAAEsCAIAAADfNCTgAAAABmJLR0QA/wD/AP+gvaeTAAAgAElEQVR4nO3dd1gUVxsF8DO7SxcFBLuxIFZUjGLB3rtYUWPDEo3GmNgbnzEmMYm9oDEajV1jNHYN9o5dVOxRbLGgUhRpW+b7AzUGd2FhtnN+T548CXN35t0FDndm7twriKIIIiLKLpm5CyAism6MUSIiSRijRESSMEaJiCRhjBIRScIYJSKShDFKRCQJY5SISBLGaM6mvjylir0gODb95Ul2HsPQ3Fna4aNceUr3/zPaWp/i4CdAkjFGbUPKn91zyQRBEASZ3N7ZvXD5ukHjVl2MN+xvtubBnnlTfvzzhvrdV8SUuGexiQkvnr1UG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dmOevTfv+3O3Y9k2KAqIoFO72875Dhw4dOnY+cuOAj2QAUmKikxztk2Li318fQBTF96NRJhPenceLwPujZZx9fJwunbub2XQEcu8O7cSdO/4+tuNc1fb1nLPwVskIGKNEAPDFF18sWLBAqVRq3yzka93ebfXQJQ5tW3m9SUTBKyBAsWPFkRgREBOfPUsQgcTwqROu9ty9te3R0TMvpvz7Yv+qyj3briYDUKakwKt2HcW+7ddTAOWdnbte+Af823G1q9qju3LRiNDzcRoAmsRXif8mqqOjffyL2LRbTLISHdoJYTPXnvMLrO9i+E+DsoQxSgRkPvJJyNe6g09S6Q6tPN/1KxWVRiz5LHZ87XK+vr51P9/8jyblwowxx1vPGOLrN+yH2juGz7/6NpMVH4+e3+5c348r+FYIGHvgtdz3y9CukQNrVavq/8n+hqH/q+vw73Hs/MZtmFX+r14VixT9qJhPvYkHX73tqgpuTXv67+9Ttfbw7XEiZMXat0n5PcynXYNcRvk8KAs4/J7ojT/++CM0NPTw4cPmLkQ/KfsGV1vR7PiqDrnNXUmOx94o0RuZjnyyJOKLXatO1+jWhBlqARijRG/oMfLJMqguz2tfJeA72ej/tXQ1dy0EntQTve/58+dFixZNtvyFUD7w9ddfT5482dxV5FCMUSIiSXhST0QkCWOUiEgSxigRkSSMUSIiSRijRESSMEaJiCRhjBIRScIYJSKShDFKRCQJY5SISBLGKBGRJIxRIiJJGKNERJIwRomIJGGMEhFJwhglIpKEMUpEJAljlIhIEsYoEZEkjFEiIkkYo0REkjBGiYgkYYwSEUnCGCUikoQxSkQkCWOUiEgSxigRkSSMUSIiSRijRESSMEaJiCRhjBIRScIYJSKShDFKRCQJY5SISBLGKBGRJIxRIiJJGKNERJIwRomIJGGMEhFJwhglIpKEMUpEJAljlIhIEsYoEZEkjFEiIkkYo0REkjBGiYgkYYwSEUnCGCUikoQxSkQkCWOUiEgSxigRkSSMUSIiSRijRESSMEaJiCRhjBIRSfJ/YAm7jPyDiEoAAAAASUVORK5CYII="
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- We can draw small charts in the notebook.\n",
    "-- This example is taken from the haskell-chart documentation.\n",
    "import Graphics.Rendering.Chart \n",
    "import Data.Default.Class\n",
    "import Control.Lens\n",
    "\n",
    "let values = [\n",
    "     (\"Mexico City\"  , 19.2, 0),\n",
    "     (\"Mumbai\"       , 12.9, 10), \n",
    "     (\"Sydney\"       , 4.3,  0),\n",
    "     (\"London\"       , 8.3,  0), \n",
    "     (\"New York\"     , 8.2,  25)]\n",
    "     \n",
    "pitem (s, v, o) = pitem_value .~ v\n",
    "                $ pitem_label .~ s\n",
    "                $ pitem_offset .~ o\n",
    "                $ def  \n",
    "\n",
    "-- Convert to a renderable in order to display it.\n",
    "toRenderable \n",
    "  $ pie_title .~ \"Relative Population\"\n",
    "  $ pie_plot . pie_data .~ map pitem values\n",
    "  $ def"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In addition to displaying outputs in a rich format, IHaskell has a bunch of useful features.\n",
    "\n",
    "For instance, the popular linting tool `hlint` is integrated and turned on by default. Let's write some ugly code, and see what it tells us:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>/* Styles used for the Hoogle display in the pager */\n",
       ".hoogle-doc {\n",
       "display: block;\n",
       "padding-bottom: 1.3em;\n",
       "padding-left: 0.4em;\n",
       "}\n",
       ".hoogle-code {\n",
       "display: block;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "}\n",
       ".hoogle-text {\n",
       "display: block;\n",
       "}\n",
       ".hoogle-name {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-head {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-sub {\n",
       "display: block;\n",
       "margin-left: 0.4em;\n",
       "}\n",
       ".hoogle-package {\n",
       "font-weight: bold;\n",
       "font-style: italic;\n",
       "}\n",
       ".hoogle-module {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-class {\n",
       "font-weight: bold;\n",
       "}\n",
       ".get-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "white-space: pre-wrap;\n",
       "}\n",
       ".show-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "margin-left: 1em;\n",
       "}\n",
       ".mono {\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "}\n",
       ".err-msg {\n",
       "color: red;\n",
       "font-style: italic;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "display: block;\n",
       "}\n",
       "#unshowable {\n",
       "color: red;\n",
       "font-weight: bold;\n",
       "}\n",
       ".err-msg.in.collapse {\n",
       "padding-top: 0.7em;\n",
       "}\n",
       ".highlight-code {\n",
       "white-space: pre;\n",
       "font-family: monospace;\n",
       "}\n",
       ".suggestion-warning { \n",
       "font-weight: bold;\n",
       "color: rgb(200, 130, 0);\n",
       "}\n",
       ".suggestion-error { \n",
       "font-weight: bold;\n",
       "color: red;\n",
       "}\n",
       ".suggestion-name {\n",
       "font-weight: bold;\n",
       "}\n",
       "</style><div class=\"suggestion-name\" style=\"clear:both;\">Redundant $</div><div class=\"suggestion-row\" style=\"float: left;\"><div class=\"suggestion-warning\">Found:</div><div class=\"highlight-code\" id=\"haskell\">f $ 3</div></div><div class=\"suggestion-row\" style=\"float: left;\"><div class=\"suggestion-warning\">Why Not:</div><div class=\"highlight-code\" id=\"haskell\">f 3</div></div><div class=\"suggestion-name\" style=\"clear:both;\">Redundant do</div><div class=\"suggestion-row\" style=\"float: left;\"><div class=\"suggestion-warning\">Found:</div><div class=\"highlight-code\" id=\"haskell\">do return 3</div></div><div class=\"suggestion-row\" style=\"float: left;\"><div class=\"suggestion-warning\">Why Not:</div><div class=\"highlight-code\" id=\"haskell\">return 3</div></div>"
      ],
      "text/plain": [
       "Line 1: Redundant $\n",
       "Found:\n",
       "f $ 3\n",
       "Why not:\n",
       "f 3Line 1: Redundant do\n",
       "Found:\n",
       "do return 3\n",
       "Why not:\n",
       "return 3"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- There is also hlint integration enabled by default.\n",
    "-- If you write sketchy code, it will tell you:\n",
    "f :: Int -> Int\n",
    "f x = x + 1\n",
    "\n",
    "-- Most warnings are orange...\n",
    "f $ 3\n",
    "\n",
    "do\n",
    "  return 3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you're an experienced Haskeller, though, and don't want `hlint` telling you what to do, you can easily turn it off:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "-- If hlint annoys you, though, you can turn it off.\n",
    "-- Note that this only takes effect in the next cell execution.\n",
    ":opt no-lint"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- You could similarly use `:opt lint` to turn it back on.\n",
    "f $ 3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In addition to `hlint` integration, IHaskell also integrates **Hoogle** for documentation searches. IHaskell provides two directives for searching Hoogle. The first of these, `:document` (or shorthands), looks for exact matches."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {},
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<style>/* Styles used for the Hoogle display in the pager */\n",
       ".hoogle-doc {\n",
       "display: block;\n",
       "padding-bottom: 1.3em;\n",
       "padding-left: 0.4em;\n",
       "}\n",
       ".hoogle-code {\n",
       "display: block;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "}\n",
       ".hoogle-text {\n",
       "display: block;\n",
       "}\n",
       ".hoogle-name {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-head {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-sub {\n",
       "display: block;\n",
       "margin-left: 0.4em;\n",
       "}\n",
       ".hoogle-package {\n",
       "font-weight: bold;\n",
       "font-style: italic;\n",
       "}\n",
       ".hoogle-module {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-class {\n",
       "font-weight: bold;\n",
       "}\n",
       ".get-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "white-space: pre-wrap;\n",
       "}\n",
       ".show-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "margin-left: 1em;\n",
       "}\n",
       ".mono {\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "}\n",
       ".err-msg {\n",
       "color: red;\n",
       "font-style: italic;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "display: block;\n",
       "}\n",
       "#unshowable {\n",
       "color: red;\n",
       "font-weight: bold;\n",
       "}\n",
       ".err-msg.in.collapse {\n",
       "padding-top: 0.7em;\n",
       "}\n",
       ".highlight-code {\n",
       "white-space: pre;\n",
       "font-family: monospace;\n",
       "}\n",
       ".suggestion-warning { \n",
       "font-weight: bold;\n",
       "color: rgb(200, 130, 0);\n",
       "}\n",
       ".suggestion-error { \n",
       "font-weight: bold;\n",
       "color: red;\n",
       "}\n",
       ".suggestion-name {\n",
       "font-weight: bold;\n",
       "}\n",
       "</style><span class='err-msg'>No result: no matching identifiers found.</span>\n"
      ],
      "text/plain": [
       "No response available: no matching identifiers found."
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    ":doc filterM"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The other provided command is `:hoogle`. This does a normal Hoogle search, and thus lets you use imperfect matching and searching by type signature. This will show you documentation for things that match the desired type signature, as demonstrated below. It automatically formats inline Haskell code and hyperlinks the identifiers to their respective Haddock documentations."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {},
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<style>/* Styles used for the Hoogle display in the pager */\n",
       ".hoogle-doc {\n",
       "display: block;\n",
       "padding-bottom: 1.3em;\n",
       "padding-left: 0.4em;\n",
       "}\n",
       ".hoogle-code {\n",
       "display: block;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "}\n",
       ".hoogle-text {\n",
       "display: block;\n",
       "}\n",
       ".hoogle-name {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-head {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-sub {\n",
       "display: block;\n",
       "margin-left: 0.4em;\n",
       "}\n",
       ".hoogle-package {\n",
       "font-weight: bold;\n",
       "font-style: italic;\n",
       "}\n",
       ".hoogle-module {\n",
       "font-weight: bold;\n",
       "}\n",
       ".hoogle-class {\n",
       "font-weight: bold;\n",
       "}\n",
       ".get-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "white-space: pre-wrap;\n",
       "}\n",
       ".show-type {\n",
       "color: green;\n",
       "font-weight: bold;\n",
       "font-family: monospace;\n",
       "margin-left: 1em;\n",
       "}\n",
       ".mono {\n",
       "font-family: monospace;\n",
       "display: block;\n",
       "}\n",
       ".err-msg {\n",
       "color: red;\n",
       "font-style: italic;\n",
       "font-family: monospace;\n",
       "white-space: pre;\n",
       "display: block;\n",
       "}\n",
       "#unshowable {\n",
       "color: red;\n",
       "font-weight: bold;\n",
       "}\n",
       ".err-msg.in.collapse {\n",
       "padding-top: 0.7em;\n",
       "}\n",
       ".highlight-code {\n",
       "white-space: pre;\n",
       "font-family: monospace;\n",
       "}\n",
       ".suggestion-warning { \n",
       "font-weight: bold;\n",
       "color: rgb(200, 130, 0);\n",
       "}\n",
       ".suggestion-error { \n",
       "font-weight: bold;\n",
       "color: red;\n",
       "}\n",
       ".suggestion-name {\n",
       "font-weight: bold;\n",
       "}\n",
       "</style><span class='hoogle-name'><a target='_blank' href='https://hackage.haskell.org/package/base/docs/Data-STRef.html#v:newSTRef'><s0>newSTRef</s0></a> &#x2237; a &#x2192; ST s (STRef s a)</span><div class='hoogle-doc'>Build a new <a>STRef</a> in the current state thread\n",
       "</div>\n",
       "<span class='hoogle-name'><a target='_blank' href='https://hackage.haskell.org/package/base/docs/Data-STRef-Lazy.html#v:newSTRef'><s0>newSTRef</s0></a> &#x2237; a &#x2192; ST s (STRef s a)</span><div class='hoogle-doc'></div>\n",
       "<span class='hoogle-name'><a target='_blank' href='https://hackage.haskell.org/package/rebase/docs/Rebase-Prelude.html#v:newSTRef'><s0>newSTRef</s0></a> &#x2237; () &#x21D2; a &#x2192; ST s (STRef s a)</span><div class='hoogle-doc'>Build a new <a>STRef</a> in the current state thread\n",
       "</div>\n",
       "<span class='hoogle-name'><a target='_blank' href='https://hackage.haskell.org/package/open-witness/docs/Data-OpenWitness-ST.html#v:newSTRef'><s0>newSTRef</s0></a> &#x2237; a &#x2192; ST s (STRef s a)</span><div class='hoogle-doc'></div>\n"
      ],
      "text/plain": [
       "<s0>newSTRef</s0> :: a -> ST s (STRef s a)\n",
       "URL: https://hackage.haskell.org/package/base/docs/Data-STRef.html#v:newSTRef\n",
       "Build a new <a>STRef</a> in the current state thread\n",
       "\n",
       "<s0>newSTRef</s0> :: a -> ST s (STRef s a)\n",
       "URL: https://hackage.haskell.org/package/base/docs/Data-STRef-Lazy.html#v:newSTRef\n",
       "\n",
       "<s0>newSTRef</s0> :: () => a -> ST s (STRef s a)\n",
       "URL: https://hackage.haskell.org/package/rebase/docs/Rebase-Prelude.html#v:newSTRef\n",
       "Build a new <a>STRef</a> in the current state thread\n",
       "\n",
       "<s0>newSTRef</s0> :: a -> ST s (STRef s a)\n",
       "URL: https://hackage.haskell.org/package/open-witness/docs/Data-OpenWitness-ST.html#v:newSTRef"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    ":hoogle :: a -> ST s (STRef s a)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you need a refresher on all of the options, you can just use `:help`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "The following commands are available:\n",
       "    :extension <Extension>    -  Enable a GHC extension.\n",
       "    :extension No<Extension>  -  Disable a GHC extension.\n",
       "    :type <expression>        -  Print expression type.\n",
       "    :info <name>              -  Print all info for a name.\n",
       "    :hoogle <query>           -  Search for a query on Hoogle.\n",
       "    :doc <ident>              -  Get documentation for an identifier via Hogole.\n",
       "    :set -XFlag -Wall         -  Set an option (like ghci).\n",
       "    :option <opt>             -  Set an option.\n",
       "    :option no-<opt>          -  Unset an option.\n",
       "    :?, :help                 -  Show this help text.\n",
       "\n",
       "Any prefix of the commands will also suffice, e.g. use :ty for :type.\n",
       "\n",
       "Options:\n",
       "  lint        – enable or disable linting.\n",
       "  svg         – use svg output (cannot be resized).\n",
       "  show-types  – show types of all bound names\n",
       "  show-errors – display Show instance missing errors normally.\n",
       "  pager       – use the pager to display results of :info, :doc, :hoogle, etc."
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    ":help"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "All of the code you normally put into IHaskell is (like in GHCi) interpreted. However, sometimes you've perfected a function, and now need it to run faster. In that case, you can go ahead and define a module in a single cell. As long as your module has a module header along the lines of `module Name where`, IHaskell will recognize it as a module. It will create the file `A/B.hs`, compile it, and load it. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "-- If your code isn't running fast enough, you can just put it into a module.\n",
    "module A.B where\n",
    "\n",
    "fib 0 = 1\n",
    "fib 1 = 1\n",
    "fib n = fib (n-1) + fib (n-2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that the module is by default imported unqualified, as though you had typed `import A.B`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10946"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "10946"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- The module is automatically imported unqualified.\n",
    "print $ A.B.fib 20\n",
    "print $ fib 20"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that since a new module is imported, all previous bound identifiers are now unbound. For instance, we no longer have access to the `f` function from before:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "ename": "",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "<interactive>:1:1: error: Variable not in scope: f :: Integer -> t"
     ]
    }
   ],
   "source": [
    "f 3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "However, if you re-import this module with another import statement, the original implicit import goes away."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10946"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "10946"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import qualified A.B as Fib\n",
    "\n",
    "Fib.fib 20\n",
    "fib 20"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Thanks!\n",
    "---\n",
    "\n",
    "That's it for now! I hope you've enjoyed this little demo of **IHaskell**! There are still a few features that I haven't covered, such as the `show-types` and `show-errors` options, as well as the relatively intelligent autocompletion mechanism and inline type info popups.\n",
    "\n",
    "I hope you find IHaskell useful, and please report any bugs or features requests [on Github](https://github.com/gibiansky/IHaskell/issues). If you have any comments, want to contribute, or just want to get in touch, don't hesitate to contact me at Andrew dot Gibiansky at Gmail. Contributions are also more than welcome, and I'm happy to help you get started with IHaskell development if you'd like to contribute!\n",
    "\n",
    "Thank you to [Adam Vogt](https://github.com/aavogt), [Stian Håklev](http://reganmian.net/), and [@edechter](https://github.com/edechter) for their testing, bug reporting, pull requests, and general patience!"
   ]
  }
 ],
 "metadata": {
  "hide_input": false,
  "kernelspec": {
   "display_name": "Haskell",
   "language": "haskell",
   "name": "haskell"
  },
  "language_info": {
   "codemirror_mode": "ihaskell",
   "file_extension": ".hs",
   "mimetype": "text/x-haskell",
   "name": "haskell",
   "pygments_lexer": "Haskell",
   "version": "8.10.4"
  },
  "latex_envs": {
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 0
  },
  "nav_menu": {},
  "toc": {
   "navigate_menu": true,
   "number_sections": true,
   "sideBar": true,
   "threshold": 6,
   "toc_cell": false,
   "toc_section_display": "block",
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
